#!/bin/bash

VIP=172.17.100.100
VPORT=89
RPORT=89

RS=("172.17.0.8" "172.17.0.6")
RSW=("1" "1")
TYPE=g

addrs() {
    ipvsadm -a -t $VIP:$VPORT -r $1:$RPORT -$TYPE -w $2
    [ $? -eq 0 ] && return 0 || return 1
}

echo 1 > /proc/sys/net/ipv4/ip_forward

ip addr add $VIP broadcast $VIP label eth0:0 dev eth0
ipvsadm -A -t $VIP:$VPORT -s wlc

COUNT=0
for I in ${RS[*]}; do
addrs $I ${RSW[$COUNT]}
let COUNT++
done